package com.jiegui.business.controller;

import java.util.Arrays;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jiegui.common.annotation.Log;
import com.jiegui.common.core.controller.BaseController;
import com.jiegui.common.core.domain.AjaxResult;
import com.jiegui.common.enums.BusinessType;
import com.jiegui.business.domain.GoodsOrderInfo;
import com.jiegui.business.service.GoodsOrderInfoService;
import com.jiegui.common.utils.poi.ExcelUtil;
import com.jiegui.common.core.page.TableDataInfo;

/**
 * 商品订单Controller
 * 
 * @author wuqicheng
 * @date 2024-11-20
 */
@RestController
@RequestMapping("/business/goodsOrderInfo")
public class GoodsOrderInfoController extends BaseController
{
    @Resource
    private GoodsOrderInfoService goodsOrderInfoService;

    /**
     * 查询商品订单列表
     */
    @PreAuthorize("@ss.hasPermi('business:goodsOrderInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(GoodsOrderInfo goodsOrderInfo)
    {
        startPage();
        List<GoodsOrderInfo> list = goodsOrderInfoService.selectGoodsOrderInfoList(goodsOrderInfo);
        return getDataTable(list);
    }

    /**
     * 导出商品订单列表
     */
    @PreAuthorize("@ss.hasPermi('business:goodsOrderInfo:export')")
    @Log(title = "商品订单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GoodsOrderInfo goodsOrderInfo)
    {
        List<GoodsOrderInfo> list = goodsOrderInfoService.selectGoodsOrderInfoList(goodsOrderInfo);
        ExcelUtil<GoodsOrderInfo> util = new ExcelUtil<GoodsOrderInfo>(GoodsOrderInfo.class);
        return util.exportExcel(list, "商品订单数据");
    }

    /**
     * 获取商品订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:goodsOrderInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(goodsOrderInfoService.selectGoodsOrderInfoById(id));
    }

    /**
     * 新增商品订单
     */
    @PreAuthorize("@ss.hasPermi('business:goodsOrderInfo:add')")
    @Log(title = "商品订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GoodsOrderInfo goodsOrderInfo)
    {
        return toAjax(goodsOrderInfoService.insertGoodsOrderInfo(goodsOrderInfo));
    }

    /**
     * 修改商品订单
     */
    @PreAuthorize("@ss.hasPermi('business:goodsOrderInfo:edit')")
    @Log(title = "商品订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GoodsOrderInfo goodsOrderInfo)
    {
        return toAjax(goodsOrderInfoService.updateGoodsOrderInfo(goodsOrderInfo));
    }

    /**
     * 删除商品订单
     */
    @PreAuthorize("@ss.hasPermi('business:goodsOrderInfo:remove')")
    @Log(title = "商品订单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(goodsOrderInfoService.removeByIds(Arrays.asList(ids)));
    }


}
